﻿package blob.levelstates
{
    import blob.*;
    import org.flixel.*;

    public class LevelState2 extends PlayState
    {
        private var ImgTiles:Class;
        private var Bg:Class;
        private var DataMap:Class;
        public var textSpace:FlxText;
        public var textTab:FlxText;

        public function LevelState2()
        {
            this.ImgTiles = LevelState2_ImgTiles;
            this.Bg = LevelState2_Bg;
            this.DataMap = LevelState2_DataMap;
            return;
        }// end function

        override public function create() : void
        {
            super.create();
            QID = 2;
            var _loc_1:* = new FlxSprite(0, 0, this.Bg);
            add(_loc_1);
            levelName.text = Blob.level2Name;
            this.textSpace = new FlxText(400, 400, 200, "SPACE to merge/split");
            this.textTab = new FlxText(50, 250, 200, "Q to toggle");
            this.textTab.setFormat(null, 16);
            this.textSpace.setFormat(null, 16);
            add(this.textTab);
            add(this.textSpace);
            this.textSpace.kill();
            _map1 = new FlxTilemap();
            mechanisms = new FlxGroup(30);
            activeChar = 0;
            curChars = new Array();
            loadMap(new this.DataMap(), _map1, this.ImgTiles, 10, 10);
            FlxG.bgColor = 4287137928;
            finishCharSize = 2;
            thisLevelClass = LevelState2;
            nextLevelClass = LevelState3;
            twoStarTime = 15;
            threeStarTime = 8;
            pause = new PauseMenu();
            return;
        }// end function

        override public function update() : void
        {
            super.update();
            if (FlxG.overlap(characterGroup, curChars[activeChar]))
            {
                this.textSpace.x = curChars[activeChar].x - 50;
                this.textSpace.y = curChars[activeChar].y - 100;
                this.textSpace.revive();
            }
            else if (this.textSpace.alive)
            {
                this.textSpace.kill();
            }
            return;
        }// end function

    }
}
